using System;
using System.Data;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class DropDownListPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
         if(!IsPostBack)
         {
            LoadData();
            this.Literal1.Text = 
            DropDownList1.SelectedValue 
            + "-" + DropDownList1.SelectedItem.Text;
            this.Literal2.Text = 
            DropDownList2.SelectedValue 
            + "-" + DropDownList2.SelectedItem.Text;
         }
    }
    void LoadData()
    {
        string connectionString =
                WebConfigurationManager.ConnectionStrings[
                "RCVDB2000"].ConnectionString;

        ControlHelper cls = new
        ControlHelper(connectionString);
        cls.CommandText = "select * from tblProvinces";
        cls.CommandType = CommandType.Text;
        cls.InitProperties();
        cls.FillDataTableToDropDownList(
        this.DropDownList1, 
        "ProvinceName", "ProvinceID","");        
        cls.FillArrayListToDropDownList(
        this.DropDownList2, "None", "",""); 
        cls.Finalize();
    }
     
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList dropDownList=(DropDownList)sender;
        this.Literal1.Text= 
        dropDownList.SelectedValue +"-" 
        + dropDownList.SelectedItem.Text;
    }
    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList dropDownList = (DropDownList)sender;
        this.Literal2.Text = 
        dropDownList.SelectedValue + "-" 
        + dropDownList.SelectedItem.Text;
    }
}
